package io.renren.modules.bike.service.impl;

import io.renren.modules.bike.entity.OrdersEntity;
import org.springframework.stereotype.Service;

import java.util.Map;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;

import io.renren.modules.bike.dao.PlaceDao;
import io.renren.modules.bike.entity.PlaceEntity;
import io.renren.modules.bike.service.PlaceService;


@Service("placeService")
public class PlaceServiceImpl extends ServiceImpl<PlaceDao, PlaceEntity> implements PlaceService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        String key = (String) params.get("key");
        IPage<PlaceEntity> page = null;
        if (key != null) {
            page = this.page(
                    new Query<PlaceEntity>().getPage(params),
                    new QueryWrapper<PlaceEntity>().like("p_name", key)
                            .or().like("p_address", key).or()
                            .like("p_comment", key)
            );
        } else {
            page = this.page(
                    new Query<PlaceEntity>().getPage(params),
                    new QueryWrapper<PlaceEntity>()
            );
        }

        return new PageUtils(page);
    }

}
